#include "AddrInfo.h"

AddrInfo::AddrInfo(string ip, string port)
:targetAddr_(nullptr)
{
    sourceAddr_.ai_socktype = SOCK_STREAM;
    sourceAddr_.ai_protocol = IPPROTO_TCP;
    sourceAddr_.ai_family = AF_UNSPEC;

    getaddrinfo(ip.c_str(), port.c_str(), &sourceAddr_, &targetAddr_);
}

AddrInfo::~AddrInfo()
{
}

addrinfo* AddrInfo::getAddrInfo()
{
    return targetAddr_;
}

void AddrInfo::freeTargetAddr()
{
    freeaddrinfo(targetAddr_);
}
